/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ia_0.data_model.character;

import ia_0.data_model.actions.Action;
import ia_0.data_model.actions.ActionDormir;
import ia_0.data_model.actions.ActionManger;
import java.util.ArrayList;
import java.util.LinkedList;


/**
 *
 * @author yguo
 */
public class CharacterAction {
    
    public ArrayList<Action> priorite = new ArrayList<Action>();
    public LinkedList<Action> strategie = new LinkedList<Action>();


    public CharacterAction (Character c) {
        priorite.add(new ActionDormir(c));
        priorite.add(new ActionManger(c));
    }

    public CharacterAction(){
        
    }



    public void strategie(){
        for (Action a:priorite){
            boolean b=  a.getCommence();
            boolean b1= a.toDo();
            boolean b2= a.toDoTimer();
            if(b || b1 ||b2){
                strategie.remove(a);
                strategie.addFirst(a);
            }
        }

    }

    public void agit() {
        if (!strategie.isEmpty()) {
            Action a = strategie.getFirst();

            a.setCommence();
            a.doIt();

            if (a.getTermine()) {
                strategie.remove(a);
                a.raz();
            }

        }

    }


  

}
